package cn.zhouchao.basic.eunm;

import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
import java.util.Optional;

/**
 * 店铺状态枚举
 */
@Getter
@AllArgsConstructor
public enum  ShopStateEnum {
    WAIT_AUDIT_STATE(0,"待审核"),
    PASS_AUDIT_STATE(1,"审核通过"),
    WAIT_ACTIVATE_STATE(2,"待激活"),
    REJECT_AUDIT_STATE(3,"驳回"),
    ;
//    public static String getNameByCode(int code){ // 根据传进来的 code 返回对应的name 比如传入0 那么返回 待审核
//        Optional<ShopStateEnum> first = Arrays.stream(ShopStateEnum.values())
//                .filter(en -> en.getCode() == code).findFirst();
//        if (!first.isPresent()){
//            return "";
//        }
//        return first.get().getName();
//    }
    public static String getName(int code) {
        Optional<ShopStateEnum> first = Arrays.stream(ShopStateEnum.values())
                .filter(en -> en.getCode() == code).findFirst();
        if (!first.isPresent()) {
            return "";
        }
        return first.get().getName();
    }
    /*魔法值*/
    private int code;
    /*枚举名*/
    private String name;
}
